package com.wframe.project.jnd.util;

import com.wframe.project.jnd.entity.MoneyOffItem;

import java.math.BigDecimal;

/**
 * Created by lwb on 2017/6/7.
 */
public class MoneyOffPromotionHandler extends PromotionHandler {
    private MoneyOffItem item;

    public MoneyOffPromotionHandler(MoneyOffItem item) {
        this.item = item;
    }

    public MoneyOffItem handleRequest(BigDecimal price) {
        if (price.compareTo(this.item.getOffMoney()) >= 0) {
            this.item.setAvailable(true);
        } else {
            MoneyOffPromotionHandler successor = (MoneyOffPromotionHandler) getSuccessor();
            if (successor != null) {
                return successor.handleRequest(price);
            }
        }
        return this.item;
    }

}
